package com.baizan.daka.ui.presenter

import com.baizan.daka.base.BasePresenter
import com.baizan.daka.mvp.model.MeModel
import com.baizan.daka.rx.Subscriber.CommonSubscriber
import com.baizan.daka.showToast
import com.baizan.daka.ui.contract.ExtensionContract

class ExtensionPresenter(val mView: ExtensionContract.View) : BasePresenter(),
    ExtensionContract.Presenter {

    val meModel: MeModel by lazy { MeModel() }
    override fun getExtensionCode() {
        mView.showLoadingDialog()
        meModel.invitationCode()
            .subscribe(object :CommonSubscriber<String>(compositeDisposable){
                override fun onCallNext(t: String?) {
                   mView.getExtensionCodeSuccess(t!!)
                }

                override fun onCallCompleted() {
                    super.onCallCompleted()
                    mView.hideLoadingDialog()
                }

                override fun onCallError(e: String) {
                    super.onCallError(e)
                    showToast(e)
                }
            })
    }


}

